package com.esp.soccertutor.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.esp.soccertutor.R;
import com.esp.soccertutor.android.fbreader.FBReader;
import com.esp.soccertutor.util.Const;
import com.esp.soccertutor.util.Log;
import com.esp.soccertutor.util.Pref;
import com.esp.soccertutor.util.Storage;


public class ChooseActivity extends Activity{

	public static boolean IsStartUp;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);// hide window title
        
        setContentView(R.layout.choose_activity);
        
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        
        IsStartUp = false;
        
        Const.CONTEXT = ChooseActivity.this;
        
        try
        {
        	Storage.veirfyLibPath();
        }catch (Exception e) {
        	e.printStackTrace();
		}
        init();  
    }
    
    @Override
	public void onResume(){
    	
    	super.onResume();
    	
    	if(!IsStartUp)
    	{
	    	Intent objStartUp = new Intent(ChooseActivity.this,StartUp.class);
	        startActivity(objStartUp);
    	}
    	else
    	{
	    	if (Pref.getValue("GEN_SET_AUTO_LOAD_LAST_BOOK", "YES").equals("YES") && Pref.getValue("BOOK_ID", null)!= null){
	        	startActivity(new Intent(getApplicationContext(), FBReader.class));
	    	}
	    	else{
	    		
	    		Intent objStartUp = new Intent(ChooseActivity.this,ShowCaseActivity.class);
	    		objStartUp.putExtra(Const.SHOWCASE,Const.INT_SHOWCASE);
	    		objStartUp.putExtra(Const.TYPEID,Const.TYPEID_EBOOKS);
		        startActivity(objStartUp);
	       }
	                
	        this.finish();
    	}
    }
    public void init(){
    	
    	Log.print("CHOOSE ACTIVITY : :init() ","CREATE DEFAULT PREF");
    	if(Pref.getValue("DAY_NIGHT_MODE",null)==null){
    		
    		Pref.setValue("DAY_NIGHT_MODE", "DAY");
    		
    	}
    	
    }

}